package com.ccExcelUtil.validator.inList;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.Arrays;

/**
 * @author xiaozhao
 */
public class InListValidator implements ConstraintValidator<InList, String> {

    private String[] values;

    @Override
    public void initialize(InList constraintAnnotation) {
        values = constraintAnnotation.values();
    }

    @Override
    public boolean isValid(String value, ConstraintValidatorContext context) {
        return Arrays.asList(values).contains(value);
    }
}
